home *** CD-ROM | disk | FTP | other *** search
- /* RoundRect.pvrx---draw rectangles with counfigurably rounded
- corners.
- Author: Jeff Blume - March 25, 1992
- Copyright © 1992 by Stylus, Inc.
-
- Suggested "ProVector.pvrx" entries:
-
- 'Define "RoundRect Ctrl-R" "RoundRect MENU"'
- 'DefineKey R "RoundRect MENU"'
- */
-
-
- /* Get the argument list to see whether this is a MENU, or an OK */
- arg Cmd
-
- /* Try to get exclusive lock on project window.
- If can't get lock, not polite to interrupt. */
- 'Lock'
- if RC ~= 0 then exit
-
- options results
-
- ErrTxt = ""
-
- /* This loop is called from the menu */
- if Cmd = 'MENU' then 'GetUserData 2 2 2 "RoundRect OK" ""'
-
- /* This was called from GetUserData */
- if Cmd = 'OK' then
- DO
- 'GetInputPoints InPts'
- 'PushUndo'
-
- 'GetStr "Rounding Percentage? (RETURN = 20)" "OK" "CANCEL"'
- Rnd = result
- if rc ~= 0 then call Error "MACRO CANCELED"
- if Rnd = "" then Rnd = 20
-
- /* Convert percent to decimal, so user doesn't have to */
- Rnd = Rnd/100
-
- /* Initialize INDICATOR's */
- Pts.0.X = "INDICATOR"
- Pts.0.Y = 1
- Pts.5.X = "INDICATOR"
- Pts.5.Y = 1
- Pts.10.X = "INDICATOR"
- Pts.10.Y = 1
- Pts.15.X = "INDICATOR"
- Pts.15.Y = 1
-
- /* Calculate anchors and controls */
-
- /* Width (DX), height (DY) of rect, & shortest (RD) */
- /* RD is Reference Dimension for corner offsets */
- DX = InPts.1.X - InPts.0.X
- DY = InPts.1.Y - InPts.0.Y
- if abs(DX) <= abs(DY) then RD = DX
- else RD = DY
-
- /* First corner - usually lower left corner */
- Pts.1.X = InPts.0.X
- Pts.1.Y = InPts.1.Y - (RD * Rnd / 2)
- Pts.2.X = InPts.0.X
- Pts.2.Y = InPts.1.Y - (RD * Rnd / 4)
-
- Pts.3.X = InPts.0.X + (RD * Rnd / 4)
- Pts.3.Y = InPts.1.Y
- Pts.4.X = InPts.0.X + (RD * Rnd / 2)
- Pts.4.Y = InPts.1.Y
-
- /* Second corner - usually lower right corner */
- Pts.6.X = InPts.1.X - (RD * Rnd / 2)
- Pts.6.Y = InPts.1.Y
- Pts.7.X = InPts.1.X - (RD * Rnd / 4)
- Pts.7.Y = InPts.1.Y
-
- Pts.8.X = InPts.1.X
- Pts.8.Y = InPts.1.Y - (RD * Rnd / 4)
- Pts.9.X = InPts.1.X
- Pts.9.Y = InPts.1.Y - (RD * Rnd / 2)
-
- /* Third corner - usually upper right corner */
- Pts.11.X = InPts.1.X
- Pts.11.Y = InPts.0.Y + (RD * Rnd / 2)
- Pts.12.X = InPts.1.X
- Pts.12.Y = InPts.0.Y + (RD * Rnd / 4)
-
- Pts.13.X = InPts.1.X - (RD * Rnd / 4)
- Pts.13.Y = InPts.0.Y
- Pts.14.X = InPts.1.X - (RD * Rnd / 2)
- Pts.14.Y = InPts.0.Y
-
- /* Fourth corner - usually upper left corner */
- Pts.16.X = InPts.0.X + (RD * Rnd / 2)
- Pts.16.Y = InPts.0.Y
- Pts.17.X = InPts.0.X + (RD * Rnd / 4)
- Pts.17.Y = InPts.0.Y
-
- Pts.18.X = InPts.0.X
- Pts.18.Y = InPts.0.Y + (RD * Rnd / 4)
- Pts.19.X = InPts.0.X
- Pts.19.Y = InPts.0.Y + (RD * Rnd / 2)
-
- /* Draw rounded rectangle */
- 'Polygon' 20 Pts; Obj = result
- 'SelectObj' Obj
- END
- /* end "OK" loop */
-
- 'UnLock'
- EXIT
-
- ERROR:
- arg ErrTxt
- if ErrTxt ~= "" then 'GetBool ErrTxt "Cancel" "Cancel"'
- 'UnLock'
- exit
-